package bug.www;

import bug.dao.api.CategoryDao;
import bug.dao.api.UserProjectDao;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * User: Ion C. Olaru
 * Date: Sep 14, 2008 - 10:33:37 AM
 */

public class IndexController implements Controller {
    private static Log log = LogFactory.getLog(IndexController.class);
    protected ReloadableResourceBundleMessageSource txt;
    protected UserProjectDao upDao;

    public IndexController() {
        super();
        System.out.println("Constructing Index Controller.");
    }

    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
        String _t1 = ServletRequestUtils.getStringParameter(request, "_t1", "_v1");
        ModelAndView mv = new ModelAndView("/WEB-INF/views/index.jsp");
        System.out.println("INDEX Controller");
        mv.getModel().put("_t1", _t1);
        System.out.println(_t1);
        mv.getModelMap().put("up", upDao.getById(3));
        return mv;
    }

    public ReloadableResourceBundleMessageSource getTxt() {
        return txt;
    }

    public void setTxt(ReloadableResourceBundleMessageSource txt) {
        this.txt = txt;
    }

    public UserProjectDao getUpDao() {
        return upDao;
    }

    public void setUpDao(UserProjectDao upDao) {
        this.upDao = upDao;
    }

    public static Log getLog() {
        return log;
    }

    public static void setLog(Log log) {
        IndexController.log = log;
    }
}
